﻿using System;
using System.ServiceModel;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BiffenGUI.BiffenService;

namespace BiffenGUI.UserControls
{
    public partial class MemberAddBookingCurrent : UserControl
    {
        private frmMember parent = null;
        public frmMember MemberForm { get { return parent; } }
        private BiffenServiceClient service = null;

        private List<Movie> movies = null;
        private MemberAddBookingCreate createBooking = null;
        
        public MemberAddBookingCurrent()
        {
            InitializeComponent();
        }

        public void SetReferances(frmMember frm, BiffenServiceClient svc)
        {
            parent = frm;
            service = svc;

            createBooking = new MemberAddBookingCreate();
            createBooking.SetReferances(this, service);
            createBooking.Location = MovieListControl.Location;
            createBooking.Size = MovieListControl.Size;
            createBooking.Anchor = MovieListControl.Anchor;
            createBooking.Visible = false;
            this.Controls.Add(createBooking);

            LoadMovies();
        }

        private void LoadMovies()
        {
            try
            {
                movies = service.GetCurrentMovies();
            }
            catch (FaultException<BiffenDataAccessFault> ex)
            {
                MessageBox.Show(ex.Detail.Message);
            }

            MovieListControl.BuildMovieList(movies, this);
        }

        public void NextStep(Movie m)
        {
            lblHeader.Text = "< Tilbage til film valg";
            lblHeader.Cursor = Cursors.Hand;

            parent.TabMenu.SelectedIndex = 0;

            MovieListControl.Visible = false;
            createBooking.Visible = true;

            createBooking.SetSelectedMovie(m);
        }

        public void PrevStep()
        {
            lblHeader.Text = "Vælg film:";
            lblHeader.Cursor = Cursors.Default;

            MovieListControl.Visible = true;
            createBooking.Visible = false;
            createBooking.SetSelectedMovie(null);
            createBooking.SetSelectedShow(null, null);
        }

        public void UpdatePhoneNumber(string phone)
        {
            createBooking.UpdatePhoneNumber(phone);
        }

        private void MemberAddBookingStep1_DoubleClick(object sender, EventArgs e)
        {
            //LoadMovies();
        }

        private void lblHeader_Click(object sender, EventArgs e)
        {
            PrevStep();
        }


    }
}
